﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.ReportSource;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Windows;

namespace UI.Desktop
{
    public partial class frmReporteTurnos : Form
    {
        public frmReporteTurnos()
        {
            InitializeComponent();
        }

        private void cbProfesional_Click(object sender, EventArgs e)
        {
            Business.Entities.Profesional prof = new Business.Entities.Profesional();
            DataSet dsProf = new DataSet();
            dsProf = prof.ObtenerListaProfesional();
            ObtenerProfesional(dsProf);
        }

        private void ObtenerProfesional(DataSet dsProf)
        {
            cbProfesional.Text = "Seleccione el profesional";
            cbProfesional.DataSource = dsProf.Tables["Profesional"];
            string Id_profesional = dsProf.Tables["Profesional"].Columns[0].Caption.ToString();
            string apellido = dsProf.Tables["Profesional"].Columns[0].Caption.ToString();



            cbProfesional.DisplayMember = apellido;



        }

        private void btnEmitir_Click(object sender, EventArgs e)
        {
            
            
            ReportDocument rpt = new ReportDocument();
            rpt.Load(@"d:\Martin\SistemaTURNET\UI.Desktop\ReporteTurnos.rpt");
            Business.Entities.Profesional prof = new Business.Entities.Profesional();
            Business.Entities.Turno Entur = new Business.Entities.Turno();
            string Concatenado = cbProfesional.Text;
            DataSet dsProf = new DataSet();
            DataSet dsTurnos = new DataSet();
            dsProf = prof.ObtenerProfesional(Concatenado);
            string apellido = dsProf.Tables["Profesional"].Rows[0][0].ToString();
            


            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition crParameterFieldDefinition;
            ParameterValues crParameterValues = new ParameterValues();
            ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

           ;
            crParameterDiscreteValue.Value = apellido;
            crParameterFieldDefinitions = rpt.DataDefinition.ParameterFields;
            crParameterFieldDefinition = crParameterFieldDefinitions["Profesional"];
            
            crParameterValues = crParameterFieldDefinition.CurrentValues;




            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);



            rpt.SetDatabaseLogon("sa","ana");

            crystalReportViewer1.ReportSource = rpt;
            crystalReportViewer1.Refresh();
        }

        
        


    


          

    }
}
